function histogram(){ 
    var controls={}; 
    var bgColor=new Array("#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de","#4876de"); 
    this.init=function(data,y){ 
        setControls(); 
        buildHtml(data,y); 
    } 
    function setControls(){ 
        controls.histogramContainer=$("#histogram-container"); 
        controls.histogramBgLineUL=controls.histogramContainer.children("div.histogram-bg-line"); 
        controls.histogramContentUL=controls.histogramContainer.children("div.histogram-content"); 
        controls.histogramY=controls.histogramContainer.children("div.histogram-y"); 
    } 
    function buildHtml(data,y){ 
        var len=data.length,perArr=new Array(),maxNum,maxTotal,yStr=''; 
        var contentStr='',bgLineStr='',bgLineAll=''; 
        //var widthPer=Math.floor(100/len); 
        var widthPer=1.9; 
        minWidth=10; 
        controls.histogramContainer.css("min-width",minWidth+"em"); 
         
        for(var a=0;a<len;a++){ 
            perArr[a]=parseInt(data[a]['per']);      
        } 

        maxNum=String(perArr.max()); 
        console.log(maxNum.length)
        if(maxNum.length>2){ 
            var x=parseInt(maxNum.substr(maxNum.length-2,1))+1; 
            maxTotal=Math.floor(parseInt(maxNum/100))*100+x*10; 

        }else{ 
            maxTotal=Math.floor(parseInt(maxNum/10))*10+10; 

        } 
         console.log(maxNum)
        //y轴部分 
        if(y=="%"){ 
            yStr+='<li>30</li><li>25</li><li>20</li><li>15</li><li>10</li><li>5</li><li>0</li>';            
        }else{ 
            var avg=maxTotal/5; 
            for(i=6;i>=0;i--){ 
                yStr+='<li>'+avg*i+'</li>'; 
            } 
        } 


        
        //柱状条部分 
        for(var i=0;i<len;i++){ 
            var per=Math.floor(parseInt(data[i]['per'])/maxTotal*100); 
           
            var n=Math.floor(parseInt(per)/10); 

            contentStr+='<li style="width:'+widthPer+'em">'; 
            contentStr+='<span class="histogram-box"><a style="height:'+per+'%'+';background:'+bgColor[n]+';" title="'+data[i]['per']+'"><span>'+data[i]['per']+'<span></a></span><span class="histogram-name">'+data[i]['name']+'</span>'; 
            contentStr+='</li>'; 
            bgLineStr+='<li style="width:'+widthPer+'em"><div></div></li>'; 
        } 
         
        //背景方格部分 
        for(var j=0;j<5;j++){ 
            bgLineAll+='<ul>'+bgLineStr+'</ul>'; 
        } 
        bgLineAll='<div class="histogram-bg-line">'+bgLineAll+'</div>'; 
        contentStr='<div class="histogram-content"><img src="./lib/p.jpg" /><ul>'+contentStr+'</ul></div>'; 
        yStr='<div class="histogram-y"><img src="./lib/d.png" /><ul>'+yStr+'</ul></div>'; 
        controls.histogramContainer.html(bgLineAll+contentStr+yStr); 
        //controls.histogramContainer.css("height",controls.histogramContainer.height()+"px");//主要是解决IE6中的问题       
        controls.histogramContainer.css("height","7.5em");//主要是解决IE6中的问题       
    } 
} 
Array.prototype.max = function(){//最大值 
 return Math.max.apply({},this)  
}